# 改变<prefix>为ctrl+q
#unbind ^b
#set -g prefix 'C-q'
# prefix+r
bind r source-file ~/.tmux.conf \; display-message "config reloaded"
bind escape copy-mode
bind-key -Tcopy-mode-vi 'v' send -X begin-selection
bind-key -Tcopy-mode-vi 'y' send -X copy-selection
unbind p
bind p pasteb
setw -g mode-keys vi      # Vi风格选择文本
set -g mouse on

bind h select-pane -L       # 切换到左边的 Pane
bind j select-pane -D       # 切换到下边的 Pane
bind k select-pane -U       # 切换到上边的 Pane
bind l select-pane -R       # 切换到右边的 Pane
bind L resize-pane -L 10    # 向左扩展
bind R resize-pane -R 10    # 向右扩展
bind K resize-pane -U 5     # 向上扩展
bind J resize-pane -D 5     # 向下扩展

is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n C-h if-shell "$is_vim" "send-keys C-h"  "select-pane -L"
bind-key -n C-j if-shell "$is_vim" "send-keys C-j"  "select-pane -D"
bind-key -n C-k if-shell "$is_vim" "send-keys C-k"  "select-pane -U"
bind-key -n C-l if-shell "$is_vim" "send-keys C-l"  "select-pane -R"
bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
bind-key -T copy-mode-vi C-h select-pane -L
bind-key -T copy-mode-vi C-j select-pane -D
bind-key -T copy-mode-vi C-k select-pane -U
bind-key -T copy-mode-vi C-l select-pane -R
bind-key -T copy-mode-vi C-\ select-pane -l
